<?php if (!defined('THINK_PATH')) exit();?>
<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <base href="/tpshop/">

    <title>我的电商系统后台</title>

   <link href="/tpshop/Public/admin/css/bootstrap.min.css" rel="stylesheet">
<link href="/tpshop/Public/admin/font-awesome/css/font-awesome.min.css" rel="stylesheet">
<link href="/tpshop/Public/admin/css/plugins/toastr/toastr.min.css" rel="stylesheet">
<link href="/tpshop/Public/admin/js/plugins/gritter/jquery.gritter.css" rel="stylesheet">
<link href="/tpshop/Public/admin/css/animate.css" rel="stylesheet">
<link href="/tpshop/Public/admin/css/style.css" rel="stylesheet">

</head>

<body>

    <div id="wrapper">
        <nav class="navbar-default navbar-static-side" role="navigation">
    <div class="sidebar-collapse">
        <ul class="nav metismenu" id="side-menu">
            <li class="nav-header">
                <div class="dropdown profile-element"> 
                    <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                    <span class="clear"> <span class="block m-t-xs"> <strong class="font-bold">David Williams</strong>
                     </span></span> </a>
                </div>
                <div class="logo-element">
                    IN+
                </div>
            </li>
            <li <?php if(CONTROLLER_NAME == 'Index'): ?>class="active"<?php endif; ?>>
                <a href="<?php echo U('admin/index/index');?>"><i class="fa fa-home "></i> <span class="nav-label">主页</span></a>
            </li>    
            <li <?php if(CONTROLLER_NAME == 'Order'): ?>class="active"<?php endif; ?>>
                <a href="<?php echo U('admin/order/index');?>"><i class="fa fa-shopping-cart"></i> <span class="nav-label">订单管理</span></a>
            </li>
            <li <?php if(CONTROLLER_NAME == 'Catalog'): ?>class="active"<?php endif; ?>>
                <a href="<?php echo U('admin/catalog/index');?>"><i class="fa fa-bars"></i> <span class="nav-label">分类管理</span></a>
            </li>
            <li <?php if(CONTROLLER_NAME == 'Prodect'): ?>class="active"<?php endif; ?>>
                <a href="<?php echo U('admin/prodect/prodect');?>"><i class="fa fa-gift"></i> <span class="nav-label">商品管理</span></a>
            </li>
            <li <?php if(CONTROLLER_NAME == 'Member'): ?>class="active"<?php endif; ?>>
                <a href="<?php echo U('admin/member/index');?>"><i class="fa fa-user"></i> <span class="nav-label">会员管理</span></a>
            </li>
            <li <?php if(CONTROLLER_NAME == 'Set'): ?>class="active"<?php endif; ?>>
                <a href="<?php echo U('admin/set/index');?>"><i class="fa fa-cog"></i> <span class="nav-label">网站设置</span></a>
            </li>
        </ul>
    </div>
</nav>

        <div id="page-wrapper" class="gray-bg dashbard-1">
            <div class="row border-bottom">
            <nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
                <div class="navbar-header">
                    <a class="navbar-minimalize minimalize-styl-2 btn btn-primary " href="#"><i class="fa fa-bars"></i> </a>
                </div>
                <ul class="nav navbar-top-links navbar-right">
                    <li>
                        <span class="m-r-sm text-muted welcome-message">欢迎来到我的电商系统</span>
                    </li>
                    <li>
                        <a href="<?php echo U('admin/auth/logout');?>">
                            <i class="fa fa-sign-out"></i>退出
                        </a>
                    </li>
                </ul>

            </nav>
            </div>
                   
            <div class="row">
                <div class="col-lg-12">
                 <script src="/tpshop/Public/admin/js/jquery-2.1.1.js"></script>
<script src="/tpshop/Public/admin/js/bootstrap.min.js"></script>
<script src="/tpshop/Public/admin/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="/tpshop/Public/admin/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="/tpshop/Public/admin/js/inspinia.js"></script>
<script src="/tpshop/Public/admin/js/plugins/pace/pace.min.js"></script>
<script src="/tpshop/Public/admin/js/plugins/jquery-ui/jquery-ui.min.js"></script>

                    
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
        <h2>编辑商品</h2>
        <ol class="breadcrumb">
            <li class="active">
               <strong> <a href="index.html">主页</a></strong>
            </li>
            <li>
                <a href="<?php echo U('admin/prodect/prodect');?>">编辑商品</a>
            </li>
        </ol>
    </div>
    <div class="col-lg-2">
    </div>
</div>
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <form method="post" action="<?php echo U('admin/prodect/do_edit/id/'.$prodect['id']);?>" class="form-horizontal">
            <div class="form-group"><label class="col-sm-1 control-label">商品名称</label>
                <div class="col-sm-10"><input name="title" value="<?php echo ($prodect["title"]); ?>" type="text" class="form-control"></div>
            </div>
             <div class="hr-line-dashed"></div>
             <div class="form-group"><label class="col-sm-1 control-label">分类</label>
                <div class="col-sm-2">
                    <select  class="form-control" id="level1">
                        <?php if(is_array($level1data)): $i = 0; $__LIST__ = $level1data;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$l1): $mod = ($i % 2 );++$i;?><option value="<?php echo ($l1["id"]); ?>" <?php if($l1['id'] == $level1): ?>selected="selected"<?php endif; ?>><?php echo ($l1["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
                    </select>
                </div>
                <div class="col-sm-2">
                    <input type="hidden" id="level2_default" value="<?php echo ($level2); ?>">
                    <select  class="form-control" id="level2" >
                            <option >请选择一个二级分类</option>  
                    </select>
                </div>
                <div class="col-sm-2">
                    <input type="hidden" id="level2_default" value="<?php echo ($level2); ?>">
                    <select name="catalog_id" class="form-control" id="level3" >
                            <option >请选择一个三级分类</option>  
                    </select>
                </div>
            </div>
            <div class="hr-line-dashed"></div>
             <div class="form-group"><label class="col-sm-1 control-label">价格</label>
                <div class="col-sm-3"><input name="price" type="text" class="form-control" value="<?php echo ($prodect["price"]); ?>"></div>
                <label class="col-sm-1 control-label">库存</label>
                <div class="col-sm-3"><input name="stock" type="text" class="form-control" value="<?php echo ($prodect["stock"]); ?>"></div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="form-group"><label class="col-sm-1 control-label">图片</label>
                <div class="col-sm-6"><input name="img" type="text" id="img" class="form-control" value="<?php echo ($prodect["img"]); ?>"></div>
                <div class="col-sm-2"><a href="" class="btn btn-info" id="upload">上传</a></div> 
                <div class="col-sm-2" id="preview"></div> 
            </div>
            <div class="hr-line-dashed"></div>
             <div class="form-group"><label class="col-sm-1 control-label">描述</label>
                <div class="col-sm-10"><textarea name="desc" rows="8" class="form-control" ><?php echo ($prodect["desc"]); ?></textarea></div>
            </div>
             <div class="form-group"><label class="col-sm-1 control-label">内容</label>
                <div class="col-sm-10"><textarea name="content"  rows="40" class="form-control" id="content" ><?php echo ($prodect["content"]); ?></textarea></div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="form-group"><label class="col-sm-1 control-label"></label>
                <div class="col-sm-2"><input  type="submit" class="form-control btn btn-info" ></div>
            </div>
            <div class="hr-line-dashed"></div>
        </form>
    </div>
 </div>
<script charset="utf-8" src="/tpshop/Public/other/kindeditor/kindeditor-all.js"></script>
<script charset="utf-8" src="/tpshop/Public/other/kindeditor/lang/zh-CN.js"></script>
<script charset="utf-8" src="/tpshop/Public/other/jquery.upload.js"></script>
<script>
    var editor;
    KindEditor.ready(function(K) {
        editor = K.create(["#content"],{
            uploadJson:"<?php echo U('admin/util/uploadJson');?>",
            formatUploadUrl:false,
            allowFlashUpload:false,
            allowMediaUpload:false,
            allowFileUpload:false
        });
        });
    $('#upload').click(function(){
        $.upload({
            // 上传地址
            url: '<?php echo U("/admin/util/upload");?>', 
            // 文件域名字
            fileName: 'file', 
            // 其他表单数据
            dataType: 'text',
            // 上传之前回调,return true表示可继续上传
            onSend: function() {
                    return true;
            },
            // 上传之后回调
            onComplate: function(data) {
                //alert(data);
                if(data.indexOf("upload")!=-1){
                    $('#img').val(data);
                    $('#preview').html('<img style="height:89px" src="/tpshop'+data+'"/>');
                }else{
                    alert(data);
                }      
            }   
        });
        return false;
    })
    function level1change(){
        var id=$("#level1").val();
        $.get("<?php echo U('admin/prodect/getcatalog');?>",{id:id},function(data){
            var level2_default=$('#level2_default').val();
            var s="";
            for (var i = 0; i < data.length; i++) {
               var isSelected=data[i].id==level2_default?'selected="selected"':"";
                s = s + '<option '+isSelected+' value="'+data[i].id+'">'+data[i].name+'</option>' ;                          
            };
            $('#level2').html(s);
            level2change();
        })
    }
    function level2change(){
        var id=$("#level2").val();
        $.get("<?php echo U('admin/prodect/getcatalog');?>",{id:id},function(data){
            var level3_default=$('#level3_default').val();
            var s="";
            for (var i = 0; i < data.length; i++) {
                 var isSelected=data[i].id==level3_default?'selected="selected"':"";
                s = s + '<option value="'+data[i].id+'">'+data[i].name+'</option>' ;                         
            };
            $('#level3').html(s);
        })
    }
     $('#level1').change(level1change);
      $('#level2').change(level2change);
      level1change();
</script>

                    <div class="footer">
	<div class="pull-right">
	    10GB of <strong>250GB</strong> Free.
	</div>
	<div>
	    <strong>Copyright</strong> Example Company &copy; 2014-2015
	</div>
</div>
                </div>
            </div>

        </div>
     </div>
     
</body>
</html>